package es.deusto.programacionIV.calculator.model;

import java.util.Collection;

/**
 * This interface represents a source of data related to calculator operations. It allows
 * to retrieve all the available operation types, load all the calculated operations and
 * insert a specific operation.
 * 
 * @author Iker Jamardo Zugaza
 *
 */
public interface OperationDataSource
{
	/**
	 * Initializes the operation data source.
	 * @throws Exception If there is any error while initializing the data source.
	 */
	public void init(Collection<OperationType> operationTypes) throws Exception;
	
	/**
	 * Ends the operation data source.
	 * @throws Exception If there is any error while ending the data source.
	 */
	public void end() throws Exception;
	
	/**
	 * Gets all the calculated operations.
	 * @return A collection with all the calculated operations.
	 * @throws Exception If there is any kind of error while retrieving all the calculated operations.
	 */
	public Collection<Operation> getAllCalculatedOperations() throws Exception;
	
	/**
	 * Inserts a new calculated operation in the data source.
	 * @param operation The operation to be inserted.
	 * @return The number of operations that have been inserted. The insertion process is considered to 
	 * have been successful if the return value is equals to 1.
	 * @throws Exception If there is any kind of error while inserting the calculated operation.
	 */
	public int insertCalculatedOperation(Operation operation) throws Exception;
}
